package com.jinlia.show.modules.system.controller;

import com.jinlia.show.modules.base.system.entity.GoodsLabel;
import com.jinlia.show.modules.base.system.entity.GoodsLabelRel;
import com.jinlia.show.modules.base.system.service.GoodsLabelMapperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("goods/label")
public class GoodsLabelController {

    @Autowired
    GoodsLabelMapperService goodsLabelMapperService;

    @GetMapping("/{id}")
    public ResponseEntity<GoodsLabel> getPage(@PathVariable("id") Long id) {
        GoodsLabel byId = goodsLabelMapperService.getById(id);
        return ResponseEntity.ok(byId);
    }
    /**
     * 保存或更新
     *
     * @param goodsTag
     */
    @PostMapping("saveOrUpdate")
    public void saveOrUpdate(@RequestBody GoodsLabel goodsTag) {
        goodsLabelMapperService.saveOrUpdate(goodsTag);
    }


    @PostMapping("list")
    public ResponseEntity<List<GoodsLabel>> goodsListPO(@RequestBody GoodsLabel goodsTag) {
        List<GoodsLabel> list = goodsLabelMapperService.lambdaQuery()
                .list();
        return ResponseEntity.ok(list);
    }

    @PostMapping("bindRel")
    public void bindRel(@RequestBody GoodsLabelRel goodsLabelRel) {
        goodsLabelMapperService.bindRel(goodsLabelRel);
    }
    @PostMapping("bindRemove")
    public void bindRemove(@RequestBody GoodsLabelRel goodsLabelRel) {
        goodsLabelMapperService.bindRemove(goodsLabelRel);
    }
}
